﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;

namespace LP2
{
    class Background
    {
        List<String> obstaclesRoute;
        List<BoundingBox> obstacles;
        List<Texture2D> obstaclesTexture;
        
        public char[,] matrix = new char[80, 60];

        public Background()
        {   
            obstacles=new List<BoundingBox>();
            obstaclesRoute = new List<String>();
            obstaclesTexture = new List<Texture2D>();
        }


        public void LoadContent(ContentManager Content)
        {
            //NEW : Seteamos la imagen dependiendo del tipo de atacante
            foreach (String route in obstaclesRoute)
            {
                obstaclesTexture.Add(Content.Load<Texture2D>(route));
            }

        }

        public void Draw(SpriteBatch spbtch)
        {
            int i = 0;
            spbtch.Begin();
            foreach (Texture2D t in obstaclesTexture)
            {
                spbtch.Draw(t, new Vector2(obstacles[i].Min.X,obstacles[i].Min.Y), Color.White);
                i++;
            }
        }

        public void loadMatrix(String valueXML)
        {
            
            String rutaImagen;
            String[] values;
            int x, y,sizex,sizey;



                values=valueXML.Split('/');
                
                x = Convert.ToInt32(values[0]);
                y = Convert.ToInt32(values[1]);
                sizex = Convert.ToInt32(values[2]);
                sizey = Convert.ToInt32(values[3]);
                rutaImagen = values[4];

                Vector3 v_min = new Vector3(x, y, 0);
                Vector3 v_max = new Vector3(x + sizex, y + sizey, 0);

                obstacles.Add(new BoundingBox(v_min, v_max));
                obstaclesRoute.Add(rutaImagen);
        }

        public List<BoundingBox> getObstacles()
        {
            return obstacles;
        }

    }
}
